package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.FactoryDao;
import com.aaa.ssm.entity.Factory;
import com.aaa.ssm.service.FactoryService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FactoryServiceImpl implements FactoryService {

    @Resource
    private FactoryDao factoryDao;

    @Override
    public PageInfo queryByPage(Page<Factory> page) {
        //设置分页参数
        PageHelper.startPage(page.getPageNo(),page.getPageSize());
        return new PageInfo<>(factoryDao.queryByParam(page.getData()));
    }

    @Override
    public List<Factory> queryByParam(Factory factory) {
        return factoryDao.queryByParam(factory);
    }

    @Override
    public Factory queryById(Integer factoryId) {
        return factoryDao.queryById(factoryId);
    }

    @Override
    public int add(Factory factory) {
        return factoryDao.add(factory);
    }

    @Override
    public int update(Factory factory) {
        return factoryDao.update(factory);
    }

    @Override
    public int delete(Integer factoryId) {
        return factoryDao.delete(factoryId);
    }
}
